Skip to content

Conversation

@ultrabear
Copy link

This closes #2699 by increasing the amount of documentation on fstatfs and fstatvfs to reduce confusion when writing code against these apis.

Probably could be tweaked, might be too niche or specific for top level documentation, but it would have prevented a lost day of development in practice so I thought it would be worthwhile to send a PR in regardless.

Checklist:

  • I have read CONTRIBUTING.md
  • I have written necessary tests and rustdoc comments
  • A change log has been added if this PR modifies nix's API

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I accept the changes in statfs.rs, but I don't think the changes in this file are necessary.

What I am more interested in is refactoring the function signatures to use integer types with specified width:

fn block_size(&self) -> u64

Looks like using u64 should just work as rustix uses u64 for all the Statvfs fields, but we may still want to check the concrete integer type used by those libc alias, just in case

Copy link
Author

@ultrabear ultrabear Nov 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if it was always u64, wouldn't have had a build failure
on darwin the block_size resolves to u32

Indeed, this can be trivially widened to u64, but that abstracts from the libc struct, so depends on what the goal of the library is (not in my domain of understanding)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed, this can be trivially widened to u64

Yeah, that's what I meant

Regarding this PR, do you want to merge the changes in statfs.rs? I think they are good

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fstatfs and fstatvfs appear to have flipped documentation

2 participants